import 'package:k3cloud_api/params/request_param.dart';

/// it is used to build parameters to request the push interface.
class PushParam extends RequestParam {
  @override
  String getRequestPath() {
    return "DynamicFormService.Push";
  }

  @override
  Map<String, dynamic> toJson() {
    Map<String, dynamic> data = {};
    if (numbers != null) data["numbers"] = numbers;
    if (ids != null) data["ids"] = ids;
    if (entryIds != null) data["entryIds"] = entryIds;
    if (ruleId != null) data["ruleId"] = ruleId;
    if (targetBillTypeId != null) data["targetBillTypeId"] = targetBillTypeId;
    if (targetOrgId != null) data["targetOrgId"] = targetOrgId;
    if (targetFormId != null) data["targetFormId"] = targetFormId;
    if (isEnableDefaultRule != null) data["isEnableDefaultRule"] = isEnableDefaultRule;
    if (isDraftWhenSaveFail != null) data["isDraftWhenSaveFail"] = isDraftWhenSaveFail;
    if (customParams != null) data["customParams"] = customParams;

    Map<String, dynamic> json = {};
    if (formId != null) json["formId"] = formId;
    json["data"] = data;
    return json;
  }

  String? formId;
  List<String>? numbers;
  String? ids;
  String? entryIds;
  String? ruleId;
  String? targetBillTypeId;
  int? targetOrgId;
  String? targetFormId;
  bool? isEnableDefaultRule;
  bool? isDraftWhenSaveFail;
  Map<String, dynamic>? customParams;

  static _Builder builder() {
    return _Builder();
  }
}

class _Builder {
  final PushParam _param = PushParam();

  PushParam build() => _param;
  
  _Builder formId(String formId) {
    _param.formId = formId;
    return this;
  }

  _Builder numbers(List<String> numbers) {
    _param.numbers = numbers;
    return this;
  }

  _Builder ids(List<int> ids) {
    _param.ids = ids.join(",");
    return this;
  }

  _Builder entryIds(List<int> entryIds) {
    _param.entryIds = entryIds.join(",");
    return this;
  }

  _Builder ruleId(String ruleId) {
    _param.ruleId = ruleId;
    return this;
  }

  _Builder targetBillTypeId(String targetBillTypeId) {
    _param.targetBillTypeId = targetBillTypeId;
    return this;
  }

  _Builder targetOrgId(int targetOrgId) {
    _param.targetOrgId = targetOrgId;
    return this;
  }

  _Builder targetFormId(String targetFormId) {
    _param.targetFormId = targetFormId;
    return this;
  }

  _Builder isEnableDefaultRule(bool isEnableDefaultRule) {
    _param.isEnableDefaultRule = isEnableDefaultRule;
    return this;
  }

  _Builder isDraftWhenSaveFail(bool isDraftWhenSaveFail) {
    _param.isDraftWhenSaveFail = isDraftWhenSaveFail;
    return this;
  }

  _Builder customParams(Map<String, dynamic> customParams) {
    _param.customParams = customParams;
    return this;
  }
}